package com.example.Sao.MyFragment;

import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.example.Sao.Adapter.DeviceInfoAdpter;
import com.example.Sao.MyActivity.MyApplication;
import com.example.Sao.ObjectBox.DeviceEntity;
import com.example.Sao.R;

import java.util.List;

/**
 * @ProjectName: scan
 * @Package: com.example.MyApplication.MyFragment
 * @ClassName: CheckListFragment
 * @Description: 设备列表fragment
 * @Author: 阿毛
 * @CreateDate: 2020/2/27 15:19
 * @UpdateUser: 更新者：
 * @UpdateDate: 2020/2/27 15:19
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */
public class DeviceListFragment extends LazyloadFragment {
  private CardView noting;
  private List<DeviceEntity>InfoBeanList;
  private RecyclerView mRecyclerView;
  public void setInfoBeanList(List<DeviceEntity> infoBeanList) {
    InfoBeanList = infoBeanList;
  }

  @Override
  protected boolean loadData() {
    if (InfoBeanList.size()>0) {
      DeviceInfoAdpter deviceInfoAdpter = new DeviceInfoAdpter(MyApplication.getContext(), InfoBeanList);
      mRecyclerView.setLayoutManager(new LinearLayoutManager(MyApplication.getContext()));
      mRecyclerView.setAdapter(deviceInfoAdpter);
    }else {
         mRecyclerView.setVisibility(View.GONE);
         noting.setVisibility(View.VISIBLE);
    }
    return true;
  }

  @Override
  protected void initView(View contentView) {
    mRecyclerView = contentView.findViewById(R.id.mRecyclerView);
    noting = contentView.findViewById(R.id.no);
    super.initView(contentView);
  }

  @Override
  protected int getContentLayout() {
    return R.layout.fragment_checklist;
  }
}